package com.kawins.supers.http;

import okhttp3.Call;
import okhttp3.Callback;

/**
 * @author yanwe
 * createTime 2017-12-2017/12/14 14:03
 */
public class ApiCall {

    private Call call;

    private Callback callback;

    public ApiCall(Call call, Callback callback) {
        this.call = call;
        this.callback = callback;
    }

    public Call getCall() {
        return call;
    }

    public Callback getCallback() {
        return callback;
    }

    public void reCall(){
        call.clone().enqueue(callback);
    }

    public static final class ApiCallBuilder {
        private Call call;
        private Callback callback;

        private ApiCallBuilder() {
        }

        public static ApiCallBuilder anApiCall() {
            return new ApiCallBuilder();
        }

        public ApiCallBuilder withCall(Call call) {
            this.call = call;
            return this;
        }

        public ApiCallBuilder withCallback(Callback callback) {
            this.callback = callback;
            return this;
        }

        public ApiCall build() {
            return new ApiCall(call, callback);
        }
    }
}
